﻿using UnityEngine;
using System.Collections;

public class GapPingPong : MonoBehaviour
{
    Transform up, down;
    public float MoveRange = 4f;
    public float MoveSpeed = 3f;
    float offest = 0f;
    float dir = 1f;
    void Awake()
    {
        up = transform.Find("up");
        down = transform.Find("down");
    }
    void Update()
    {
        float step = MoveSpeed * Time.deltaTime * dir;
        offest += step;
        if (offest >= MoveRange) dir = -1f;
        else if (offest <= 0f) dir = 1f;
        up.Translate(0f, step, 0f);
        down.Translate(0f, step, 0f);
    }
}
